var subject=$("#subject")
$('html, body').animate({scrollTop: $(document).height()}, 50)
$("#footer").on("input",".inputBox",function(){
	var iptval=$(this).val();
	if(iptval){
		$(".more").hide();
		$(".send").css("display","inline-block");
	}else{
		$(".send").hide();
		$(".more").css("display","inline-block");
	}
})

//$("#footer").on("click",".expression",function(){
//	$(".issuePictures").hide();
//	$(".issueExpressions").show();
//})
$("#footer").on("click",".inputBox",function(){
	$(".issuePictures").hide();
	$(".issueExpressions").hide();
	$("#subject").find("ul").css("margin-bottom","1.3rem")
})
$("#footer").on("click",".more",function(){
	$(".issuePictures").show();
	$(".issueExpressions").hide();
	$("#subject").find("ul").css("margin-bottom",$("#footer").height())
	$('html, body').animate({scrollTop: $(document).height()}, 50)
})
$("#subject").on("click",function(){
	$(".issuePictures").hide();
	$(".issueExpressions").hide();
	$("#subject").find("ul").css("margin-bottom","1.3rem")
})


    slideDown("#subject", 61, function (e) {
        var that = this;
        that.back.call();
    });

	$('.expression').qqFace({

		id : 'facebox',
		assign:'inputBox',
		path:'/static/chat/arclist/'	//表情存放的路径
	});
function replace_em(str){
	str = str.replace(/\</g,'&lt;');
	str = str.replace(/\>/g,'&gt;');
	str = str.replace(/\n/g,'<br/>');
	str = str.replace(/\[em_([0-9]*)\]/g,'<img src="static/chat/arclist/$1.gif" border="0" />');
	return str;
}




//图片显示  
       function showPics(url,name){          
         //根据路径读取到文件   
            plus.io.resolveLocalFileSystemURL(url,function(entry){  
                entry.file( function(file){  
                    var fileReader = new plus.io.FileReader();  
                    fileReader.readAsDataURL(file);  
                    fileReader.onloadend = function(e) {  
                           var picUrl = e.target.result.toString();  
                           var picIndex = $("#picIndex").val();  
                        var nowIndex = parseInt(picIndex)+1;  
                        $("#picIndex").val(nowIndex);  
                        var html = '';  
                        html = '<li class="issue clear">'
									+'<div class="issueChatImg"></div>'
									+'<img class="figureImg figureImg_l" src="img/product.png">'
									+'<img class="chat_img" src="'+picUrl+'" data-preview-src="" data-preview-group="1">'
								+'</li>';                      
                        $(".chatList").append(html);   
                  }  
               });  
          });   
       }  
        //压缩图片    
       function compressImage(url,filename){    
           var name="_doc/upload/"+filename;  
           plus.zip.compressImage({    
                   src:url,//src: (String 类型 )压缩转换原始图片的路径    
                   dst:name,//压缩转换目标图片的路径    
                   quality:40,//quality: (Number 类型 )压缩图片的质量.取值范围为1-100    
                   overwrite:true//overwrite: (Boolean 类型 )覆盖生成新文件    
               },    
               function(zip) {  
                   //页面显示图片  
                   showPics(zip.target,name);  
               },function(error) {    
                   plus.nativeUI.toast("压缩图片失败，请稍候再试");    
           });    
       }   
        
        //调用手机摄像头并拍照  
       function getImage() {    
           var cmr = plus.camera.getCamera();    
           cmr.captureImage(function(p) {    
               plus.io.resolveLocalFileSystemURL(p, function(entry) {    
                   compressImage(entry.toLocalURL(),entry.name);    
               }, function(e) {    
                   plus.nativeUI.toast("读取拍照文件错误：" + e.message);    
               });    
           }, function(e) {    
           }, {    
               filter: 'image'   
           });    
       }  
       //从相册选择照片  
       function galleryImgs() {    
            plus.gallery.pick(function(e) {    
                var name = e.substr(e.lastIndexOf('/') + 1);  
               compressImage(e,name);  
            }, function(e) {    
            }, {    
                filter: "image"    
            });    
        }  
         
       //点击事件，弹出选择摄像头和相册的选项  
        function showActionSheet() {    
            var bts = [{    
                title: "拍照"    
            }, {    
                title: "从相册选择"    
            }];    
            plus.nativeUI.actionSheet({    
                    cancel: "取消",    
                    buttons: bts    
                },    
                function(e) {    
                    if (e.index == 1) {    
                        getImage();    
                    } else if (e.index == 2) {    
                        galleryImgs();    
                    }    
                }    
            );    
        }  
        

mui.previewImage();